/*
ID:luongho3
LANG:C++
TASK:game1
*/
#include <iostream>
#include <fstream>
using namespace std;
ifstream fin("game1.in");
ofstream fout("game1.out");
#define SIZE 201
int size, num[SIZE], mat[SIZE][SIZE], acc[SIZE];
int main() {
    fin >> size;
    int i,delta,j,s;
    acc[0] = 0;
    for (i=1;i<=size;++i) {
        fin >> num[i];
        mat[i][i] = num[i];
        acc[i] = num[i] + acc[i-1];
    }
    for (delta=1;delta<=size-1;++delta) {
        for (i=1;i+delta<=size;++i) {
            j = i + delta;
            s = acc[j]-acc[i-1];
            mat[i][j] = (mat[i][j-1] < mat[i+1][j] ? s - mat[i][j-1] : s - mat[i+1][j]);
        }
    }
    fout << mat[1][size] << " " << acc[size] - mat[1][size] << "\n";
    return 0;
}
